package com.orangelife.mobile.common.biz;

import java.util.Date;

import android.os.Handler;

import com.markupartist.android.widget.PullToRefreshListView;
import com.markupartist.android.widget.PullToRefreshListView.IXListViewListener;
import com.orangelife.mobile.common.activity.OrangeLifeBaseActivity;

public abstract class PullListViewResponse extends OrangeLifeBaseActivity{
	protected void pullListView(final PullToRefreshListView lvList,final Handler mHandler) {
		lvList.setXListViewListener(new IXListViewListener() {
			@Override
			public void onRefresh() {
				mHandler.postDelayed(new Runnable() {
					@Override
					public void run() {
						refresh();
					}
				}, 2000);
			}

			@Override
			public void onLoadMore() {
				mHandler.postDelayed(new Runnable() {
					@Override
					public void run() {
                       loadMore();
					}
				}, 2000);
			}
		});
	}
	
	@SuppressWarnings("deprecation")
	 protected void onLoad(PullToRefreshListView lvList) {
		lvList.stopRefresh();
		lvList.stopLoadMore();
		lvList.setRefreshTime(new Date().toLocaleString());
	}
	
	protected abstract void refresh();
	protected abstract void loadMore();
}
